package cn.zlb.frame.infrastructure.util.persistence.merchant;

import cn.zlb.frame.domain.merchant.model.entity.MerchantEntity;
import cn.zlb.frame.domain.merchant.repository.persistence.IMerchantDomainRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.UUID;

/**
 * @author yangjie.deng@resico.cn
 * @date 2023-11-14 15:38:54
 * @describe class responsibility
 */
@Service
public class MerchantDomainRepository implements IMerchantDomainRepository {

    @Override
    @Transactional(rollbackFor = Exception.class, timeout = 3000)
    public MerchantEntity save(MerchantEntity merchantEntity) {

        String merchantNo = UUID.randomUUID().toString();

        // 模拟数据库操作
        // entity 转换为PO
        // save PO 到数据库

        merchantEntity.setMerchantNo(merchantNo);
        return merchantEntity;
    }
}
